import { http } from "@/utils/http";
import { baseUrlApi, type Result, type ListResult } from "@/utils/apiPublic";

/** 获取数据库表列表 */
export const getDbList = (params?: object) => {
  return http.request<ListResult>("get", baseUrlApi("admin/db/list"), {
    params
  });
};
//备份
export const setDbBackup= (data?: object) => {
  return http.request<Result>("post", baseUrlApi("admin/db/backup"), {
    data
  });
};
//优化
export const setDbOptimize= (data?: object) => {
  return http.request<Result>("post", baseUrlApi("admin/db/optimize"), {
    data
  });
};
//修复
export const setDbRepair= (data?: object) => {
  return http.request<Result>("post", baseUrlApi("admin/db/repair"), {
    data
  });
};
export const getFileList = (params?: object) => {
  return http.request<ListResult>("get", baseUrlApi("admin/db/file_list"), {
    params
  });
};
//删除备份文件
export const fileDel= (data?: object) => {
  return http.request<Result>("post", baseUrlApi("admin/db/file_del"), {
    data
  });
};
//下载备份文件
export const fileDownload= (params?: object) => {
  return http.request("get",baseUrlApi("admin/db/file_downlaod"),{ params },{ responseType: "blob" });
};
//导入备份文件
export const fileImport= (data?: object) => {
  return http.request<Result>("post", baseUrlApi("admin/db/file_import"), {
    data
  });
};